<?php

namespace App;

use App\Http\Services\FileManager;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\CustomerServiceImgs
 *
 * @property int $id
 * @property int $img_id 客户线索id
 * @property int $customer_service_record_id 服务记录
 * @property \Illuminate\Support\Carbon|null $deleted_at
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @method static bool|null forceDelete()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs newQuery()
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerServiceImgs onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs query()
 * @method static bool|null restore()
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereCustomerServiceRecordId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereImgId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\CustomerServiceImgs whereUpdatedAt($value)
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerServiceImgs withTrashed()
 * @method static \Illuminate\Database\Query\Builder|\App\CustomerServiceImgs withoutTrashed()
 * @mixin \Eloquent
 */
class CustomerServiceImgs extends Model
{
    use SoftDeletes;

    public static function getServicesImgUrlArray($service_record_id){
        $result = [];
        $data = self::whereCustomerServiceRecordId($service_record_id)->get();
        if (count($data) > 0){
            foreach ($data as $item){
                if ($item->img_id){
                    $url = FileManager::getImgUrl($item->img_id);
                    array_push($result,$url);
                }
            }
        }
        return $result;
    }
}
